package com.huisang.dao.role;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.huisang.dao.BaseDao;

import com.huisang.pojo.Role;


public class RoleDaoImpl implements RoleDao{
    //获取角色列表
    @Override
    public List<Role> getRoleList(Connection connection) throws SQLException {
        
        PreparedStatement preparedStatement=null;
        ResultSet resultSet=null;
        List <Role> roleList=new ArrayList<Role>();
        if(connection!=null){
            String sql="select * from smbms_role_view";
            Object[] params={};
            resultSet=BaseDao.execute(connection, preparedStatement, resultSet, sql, params);
            while(resultSet.next()){

                Role role=new Role();
                role.setId(resultSet.getInt("id"));
                role.setRoleCode(resultSet.getString("roleCode"));
                role.setRoleName(resultSet.getString("roleName"));
                roleList.add(role);

            }
            BaseDao.closeResource(null, preparedStatement, resultSet);
        }
        return roleList;
    }

    
}
